import { Component, OnInit } from '@angular/core';
import {HttpClient} from "@angular/common/http"
import {Router} from "@angular/router"
@Component({
  selector: 'app-contact-new',
  templateUrl: './contact-new.component.html',
  styleUrls: ['./contact-new.component.css']
})
export class ContactNewComponent implements OnInit {

  constructor( 
    private http:HttpClient,
    private router:Router
    ) { }

  ngOnInit(): void {
  }
public contact ={
  name:'',
  email:'',
  phone:''
}
addContact(){
  console.log(this.contact)
this.http.post("http://localhost:3000/contacts",this.contact).toPromise().then((data)=>{
console.log(data)
this.router.navigate(['/contact'])
})
}
}
